title = "新品"
url = "/daily-new.html"
layout = 'default'
==
use Jason\Ccshop\Models\Product;
use Carbon\Carbon;
function onStart(){
    $date = [];
    $offsets = [0,1,2,3,4,5,6];
    foreach($offsets as $offset ){
     array_push($date , Carbon::today()->subDays($offset)->toDateTimeString());
    }
    $this['date'] = $date;

    $pids = get('id_sort')?get('id_sort'):null;
    $pageNumber = get('page')?get('page'):1;
    if(!empty($pids)){
    Cookie::queue('idssort',$pids);

    Cookie::queue('pagenumber',$pageNumber);
    }else{
    $pids = Cookie::get('idssort');
    }

    $pida = explode(',',$pids);
    $pd = Product::InStock()->whereIn('id',$pida)->get();
    $this['adproducts'] = $pd;
    $this['pida'] = $pida;
}
==
{% partial 'catalog/ad-product' adproducts=adproducts pida=pida %}
<div class="category_content">
    <div id="popup" class="pop1">
        <ul class="r_nav">
            <li class="lis active"><a style="background: #99c1e1" date="{{date[0]}}" ></a></li>
            <li class="lis"><a style="background: #f1a291" date="{{date[1]}}" ></a></li>
            <li class="lis"><a style="background: #9bc79d" date="{{date[2]}}" ></a></li>
            <li class="lis"><a style="background: #f3b6bf" date="{{date[3]}}" ></a></li>
            <li class="lis"><a style="background: #f7c69b" date="{{date[4]}}" ></a></li>
            <li class="lis"><a style="background: #a1d6c2" date="{{date[5]}}" ></a></li>
            <li class="lis"><a style="background: #f3b6bf" date="{{date[6]}}" ></a></li>
        </ul>
    </div>
    <div class="itemList">
        <ul class="listUl">
            <li><h3 class="indexHead" id="date0"></h3></li>
            {% set newProdct100 = catalog.getSortByInstockTimeProducts()[0] %}
            {% if count(newProdct100) == 0 %}
            <p class="searchPrompt">大変申し訳ありませんが、関連商品は見つけませんでした。</p>
            {% else %}
            {% partial 'catalog/list-products2' products = newProdct100 %}
            {% endif %}
        </ul>
        <ul class="listUl">
            <li><h3 class="indexHead" id="date1"></h3></li>
            {% set newProdct100 = catalog.getSortByInstockTimeProducts()[1] %}
            {% if count(newProdct100) == 0 %}
            <p class="searchPrompt">大変申し訳ありませんが、関連商品は見つけませんでした。</p>
            {% else %}
            {% partial 'catalog/list-products2' products = newProdct100 %}
            {% endif %}
        </ul>
        <ul class="listUl">
            <li><h3 class="indexHead" id="date2"></h3></li>
            {% set newProdct100 = catalog.getSortByInstockTimeProducts()[2] %}
            {% if count(newProdct100) == 0 %}
            <p class="searchPrompt">大変申し訳ありませんが、関連商品は見つけませんでした。</p>
            {% else %}
            {% partial 'catalog/list-products2' products = newProdct100 %}
            {% endif %}
        </ul>
        <ul class="listUl">
            <li><h3 class="indexHead" id="date3"></h3></li>
            {% set newProdct100 = catalog.getSortByInstockTimeProducts()[3] %}
            {% if count(newProdct100) == 0 %}
            <p class="searchPrompt">大変申し訳ありませんが、関連商品は見つけませんでした。</p>
            {% else %}
            {% partial 'catalog/list-products2' products = newProdct100 %}
            {% endif %}
        </ul>
        <ul class="listUl">
            <li><h3 class="indexHead" id="date4"></h3></li>
            {% set newProdct100 = catalog.getSortByInstockTimeProducts()[4] %}
            {% if count(newProdct100) == 0 %}
            <p class="searchPrompt">大変申し訳ありませんが、関連商品は見つけませんでした。</p>
            {% else %}
            {% partial 'catalog/list-products2' products = newProdct100 %}
            {% endif %}
        </ul>
        <ul class="listUl">
            <li><h3 class="indexHead" id="date5"></h3></li>
            {% set newProdct100 = catalog.getSortByInstockTimeProducts()[5] %}
            {% if count(newProdct100) == 0 %}
            <p class="searchPrompt">大変申し訳ありませんが、関連商品は見つけませんでした。</p>
            {% else %}
            {% partial 'catalog/list-products2' products = newProdct100 %}
            {% endif %}
        </ul>
        <ul class="listUl">
            <li><h3 class="indexHead" id="date6"></h3></li>
            {% set newProdct100 = catalog.getSortByInstockTimeProducts()[6] %}
            {% if count(newProdct100) == 0 %}
            <p class="searchPrompt">大変申し訳ありませんが、関連商品は見つけませんでした。</p>
            {% else %}
            {% partial 'catalog/list-products2' products = newProdct100 %}
            {% endif %}
        </ul>
    </div>
</div>
<style>
    #popup{position: fixed;top: 150px;left:5px;width: 50px;text-align: center;z-index: 99;}
    #popup .lis a{padding: 5px 0;color: #fff;display: block;font-size: 12px;background: #333;}
    #popup .lis.active a{font-size: 13px;font-weight: 600;color: #000;}
    .listUl li:first-child{width: 100%;}
</style>
{% put scripts %}
<script>
$(function(){
    $("#popup .r_nav").find("li").each(function(i,item){
        var date = $(item).find("a").attr("date");
        var mouth = date.split(" ")[0].slice(5)
        $(item).find("a").text(mouth);
        $(".indexHead").eq(i).text(mouth)
    })
    /**/
    var AllHet = $(window).height();
    $('#popup .r_nav .lis').click(function(){
        var ind = $('#popup .r_nav .lis').index(this);
        var topVal = $('.itemList .listUl').eq(ind).offset().top -98;
        $('body,html').animate({scrollTop:topVal},200)
    })
   $(window).scroll(scrolls)
   scrolls()
   function scrolls(){
        var arr = new Array(7)
        var fixRight = $('#popup .r_nav .lis');
        var sTop = $(window).scrollTop();

        for(var i=0;i<arr.length;i++){
          arr[i] = $('.itemList .listUl').eq(i).offset().top-100;
          if(sTop > arr[i]){
            fixRight.eq(i).addClass('active').siblings().removeClass('active');
          }
        }
    }
})


</script>
{% endput %}